<template>
  <div style="flex:1;" class="flex">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div novalidate class="form-inline" partial>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_userinfo_id" placeholder='用户编号'
            condition="f_userinfo_id = '{}'" v-next-el='user'  v-el:userinfo
            :size="model.f_userinfo_id ? model.f_userinfo_id.length: 4">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_user_id" placeholder='表编号'
            condition="vut.f_user_id = '{}'" v-next-el='meternumber' v-el:user
            :size="model.f_user_id ? model.f_user_id.length : 3">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_user_name" placeholder='用户姓名'
            condition="f_user_name like '%{}%'" v-next-el='userphone' v-el:username
            :size="model.f_user_name ? model.f_user_name.length * 2 : 4">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_user_phone" placeholder='用户电话'
            condition="f_user_phone = '{}'"  v-next-el='userinfo'  v-el:userphone
            :size="model.f_user_phone ? model.f_user_phone.length : 4">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_area" placeholder='区域'
            condition="f_area like '%{}%'" v-el:xq v-next-el='cx' v-el:resentialarea
            :size="model.f_area ? model.f_area.length * 2 : 2">
          </div>
          <div class="form-group">
            <input  type="text" class="form-control" v-model="model.f_address" placeholder='地址'
            condition="f_address like '%{}%'" v-next-el='resentialarea' v-el:address
            :size="model.f_address ? model.f_address.length * 2 : 2">
          </div>

          <div class="form-group">
            <v-select id="f_gasproperties"
              v-model="model.f_gasproperties"
              placeholder='用气性质'
              :value.sync="model.f_gasproperties"
              :options='$parent.$parent.gasproperties'
              condition="f_gasproperties = '{}'"
              close-on-select >
            </v-select>
          </div>
          <div class="form-group">
            <v-select id="f_user_type"
              v-model="model.f_user_type"
              placeholder='用户类型'
              :value.sync="model.f_user_type"
              :options='$parent.$parent.usertypes'
              condition="f_user_type = '{}'"
              close-on-select >
            </v-select>
          </div>
          <label for="startDate">开始日期:</label>
          <datepicker id="startDate" placeholder="开始日期"
            v-model="model.startDate"
            :value.sync="model.startDate"
            :disabled-days-of-Week="[]"
            :format="'yyyy-MM-dd'"
            :show-reset-button="reset">
          </datepicker>
          <label for="endDate">结束日期:</label>
          <datepicker id="endDate" placeholder="结束日期"
            v-model="model.endDate"
            :value.sync="model.endDate"
            :disabled-days-of-Week="[]"
            :format="'yyyy-MM-dd'"
            :show-reset-button="reset">
          </datepicker>

          <label for="endDate">抄表次数</label>
          <div class="form-group">
            <v-input  id="hand_count" placeholder="抄表次数"
              :expression.sync = 'model.hand_count'
              v-model="model.hand_count"
              condition= "hand_count  {}"
              :show-reset-button="reset">
            </v-input>
          </div>

          <label for="endDate">缴费次数</label>
          <div class="form-group">
            <v-input  id="sell_count" placeholder="缴费次数"
              :expression.sync = 'model.sell_count'
              v-model="model.sell_count"
              condition= "sell_count  {}"
              :show-reset-button="reset">
            </v-input>
          </div>

          <label for="endDate">表总用气量</label>
          <div class="form-group">
            <v-input  id="f_surplus_gas_biao" placeholder="表总用气量"
              :expression.sync = 'model.f_surplus_gas_biao'
              v-model="model.f_surplus_gas_biao"
              condition= "f_surplus_gas_biao  {}"
              :show-reset-button="reset">
            </v-input>
          </div>

          <label for="endDate">户总用气量</label>
          <div class="form-group">
            <v-input  id="f_surplus_gas_hu" placeholder="户总用气量"
              :expression.sync = 'model.f_surplus_gas_hu'
              v-model="model.f_surplus_gas_hu"
              condition= "f_surplus_gas_hu  {}"
              :show-reset-button="reset">
            </v-input>
          </div>

          <div class="form-group">
            <button class="btn btn-success width-80" @click="search()" v-el:cx>查询</button>
          </div>


          <div class="form-group">
            <export-excel :data="{condition: condition}"
            :total="[{
             1: null, 2: '合计', 3: null,
             4: null, 5: null,  6: null, 7: null,
             8: $parent.$parent.model.sums.f_balance,
             9: $parent.$parent.model.sums.f_surplus_gas,
             10: null,
             11: $parent.$parent.model.sums.hand_count,
             12: $parent.$parent.model.sums.sell_count,
             13: $parent.$parent.model.sums.f_surplus_gas_biao,
             14: $parent.$parent.model.sums.f_surplus_gas_hu,
             15: null,
             16: $parent.$parent.model.sums.f_delaypay,
             17: $parent.$parent.model.sums.use_gas_money,
             18: $parent.$parent.model.sums.f_collection,
             19: $parent.$parent.model.sums.f_oughtfee_qianfei,
             20: $parent.$parent.model.sums.f_cardfees,
             21: $parent.$parent.model.sums.f_changemeter_fee}]"
            bean="稽查查询导出" sqlurl="rs/logic/exportfile"></export-excel>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
             <th>序号</th>
             <th>用户编号</th>
             <th>用户姓名</th>
             <th>开户时间</th>
             <th>表具信息</th>
             <th>最后抄表日期</th>
             <th>最后缴费日期</th>
             <th>账户余额</th>
             <th>剩余气量</th>
             <th>表底数</th>
             <th>抄表次数</th>
             <th>缴费次数</th>
             <th>表总用气量</th>
             <th>户总用气量</th>
             <th>总气费明细(1阶/2阶/3阶)</th>
             <th>滞纳金</th>
             <th>用气金额</th>
             <th>总收款</th>
             <th>欠费金额</th>
             <th>补卡金额</th>
             <th>换表金额</th>
          </tr>
        </template>
        <template partial='body'>
            <td style="text-align: center;">{{row.xuhao}}</td>
            <td style="text-align: center;">{{row.f_userinfo_id}}</td>
            <td style="text-align: center;">{{row.f_user_name}}</td>
            <th style="text-align: center;">{{row.f_createfile_date}}</th>
            <th style="text-align: center;">{{row.f_meter_info}}</th>
            <th style="text-align: center;">{{row.f_hand_date}}</th>
            <th style="text-align: center;">{{row.f_delivery_date}}</th>
            <th style="text-align: center;">{{row.f_balance.toFixed(2)}}</th>
            <th style="text-align: center;">{{row.f_surplus_gas}}</th>
            <th style="text-align: center;">{{row.f_tablebase}}</th>
            <th style="text-align: center;">{{row.hand_count}}</th>
            <th style="text-align: center;">{{row.sell_count}}</th>
            <th style="text-align: center;">{{row.f_surplus_gas_biao}}</th>
            <th style="text-align: center;">{{row.f_surplus_gas_hu}}</th>
            <th style="text-align: center;">{{row.gas_detail_zong}}</th>
            <th style="text-align: center;">{{row.f_delaypay.toFixed(2)}}</th>
            <th style="text-align: center;">{{row.use_gas_money.toFixed(2)}}</th>
            <th style="text-align: center;">{{row.f_collection.toFixed(2)}}</th>
            <th style="text-align: center;">{{row.f_oughtfee_qianfei.toFixed(2)}}</th>
            <th style="text-align: center;">{{row.f_cardfees.toFixed(2)}}</th>
            <th style="text-align: center;">{{row.f_changemeter_fee.toFixed(2)}}</th>
        </template>
        <template partial='foot'>
          <td style="text-align: center;"></td>
          <td style="text-align: center;">合计</td>
          <td style="text-align: center;"></td>
          <td style="text-align: center;"></td>
          <td style="text-align: center;"></td>
          <td style="text-align: center;"></td>
          <td style="text-align: center;"></td>
          <td style="text-align: center;">{{model.sums.f_balance.toFixed(2)}}</td>
          <td style="text-align: center;">{{model.sums.f_surplus_gas}}</td>
          <td style="text-align: center;"></td>
          <td style="text-align: center;">{{model.sums.hand_count}}</td>
          <td style="text-align: center;">{{model.sums.sell_count}}</td>
          <td style="text-align: center;">{{model.sums.f_surplus_gas_biao}}</td>
          <td style="text-align: center;">{{model.sums.f_surplus_gas_hu}}</td>
          <td style="text-align: center;"></td>
          <td style="text-align: center;">{{model.sums.f_delaypay.toFixed(2)}}</td>
          <td style="text-align: center;">{{model.sums.use_gas_money.toFixed(2)}}</td>
          <td style="text-align: center;">{{model.sums.f_collection.toFixed(2)}}</td>
          <td style="text-align: center;">{{model.sums.f_oughtfee_qianfei.toFixed(2)}}</td>
          <td style="text-align: center;">{{model.sums.f_cardfees.toFixed(2)}}</td>
          <td style="text-align: center;">{{model.sums.f_changemeter_fee.toFixed(2)}}</td>
        </template>

      </data-grid>
  </criteria-paged>
</div>
</template>
<script>
/**
*用户档案查询列表以及添加操作组件
*/
import { PagedList } from 'vue-client'
import AppData from '../../../../stores/AppData'

export default {
  title: '稽查查询',
  data () {
    return {
      model: new PagedList('rs/sql/InspectQuery', 50, {startDate: 'this.model.startDate', endDate: 'this.model.endDate'}, {f_surplus_gas_biao: '', f_surplus_gas_hu: '', f_delaypay: '', use_gas_money: '', f_collection: '',
      hand_count: '', sell_count: '', f_balance: '', f_surplus_gas: '', f_oughtfee_qianfei: '', f_cardfees: '', f_changemeter_fee: ''}),
      rows: null
    }
  },
  props: {
    excelurl: {
      type: String
    },
    condition: {
      type: String,
      default: '1=1'
    },
    row: {}
  },
  ready () {
    this.search()
  },
  methods: {
    search () {
      this.$refs.paged.$refs.cri.search()
    },
    clean () {
      this.$refs.paged.$refs.grid.select(null)
      this.$dispatch('clean')
    }
  },
  computed: {
    gasproperties () {
      return [{label: '全部', value: ''}, ...AppData.getParam('用气性质')]
    },
    usertypes () {
      return [{label: '全部', value: ''}, ...AppData.getParam('用户类型')]
    }
  }
}
</script>
<style media="screen">
  .divtext {
    min-width: 50px;
    max-width: 200px;
    border: 1px solid green;
    display: inline-block;
  }
</style>
